package com.daisuxia.back.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.daisuxia.back.dao.IMmanUserInfoDao;
import com.daisuxia.back.vo.jxl.UserReport;
import com.daisuxia.web.pojo.ContactInfo;
import com.daisuxia.web.pojo.MmanUserInfo;

@Service
public class MmanUserInfoService implements IMmanUserInfoService{
	
	@Autowired
	private IMmanUserInfoDao mmanUserInfoDao;

	@Override
	public MmanUserInfo getUserInfoById(String id) {
		return mmanUserInfoDao.get(id);
	}

	@Override
	public MmanUserInfo getxjxuser(Long id) {
		return mmanUserInfoDao.getxjxuser(id);
	}

	@Override
	public int saveNotNull(MmanUserInfo mmanUserInfo) {
		return mmanUserInfoDao.saveNotNull(mmanUserInfo);
	}
	
    /**
     * 聚信立报告
     */
	@Override
	public UserReport findJxlDetail(Map<String, Object> map) {
		UserReport ur = new UserReport();
		MmanUserInfo mmanUserInfo =  mmanUserInfoDao.findJxlDetail(map);
		if(mmanUserInfo!=null){
			if(mmanUserInfo.getJxlDetail()!=null&&!"".equals(mmanUserInfo.getJxlDetail())){
				JSONObject jxlDetailObject = JSONObject.parseObject(mmanUserInfo.getJxlDetail());
				ur= JSONObject.toJavaObject(jxlDetailObject, UserReport.class);
				ur.setRealName(mmanUserInfo.getRealname());
				ur.setGender(mmanUserInfo.getUserSex());
				ur.setIdNumber(mmanUserInfo.getIdNumber());
				ur.setAge(mmanUserInfo.getUserAge());
			}
		}
		return ur;
		
	}

	@Override
	public List<ContactInfo> getContactInfo(String phoneNum) {
		return mmanUserInfoDao.getContactInfo(phoneNum);
	}
	

}
